package com.tsunami.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tsunami.base.BaseEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @author lx
 * @date 2023/5/13 9:10
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "周-枚举")
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum Week implements BaseEnum {
    /**
     * Mon="周一"
     */
    MON("周一"),
    /**
     * Tue="周二"
     */
    TUE("周二"),
    /**
     * Wed="周三"
     */
    WED("周三"),
    /**
     * Thu="周四"
     */
    THU("周四"),
    /**
     * Fri="周五"
     */
    FRI("周五"),
    /**
     * Sat="周六"
     */
    SAT("周六"),
    /**
     * Sun="周日"
     */
    SUN("周日"),
    ;

    @Schema(description = "描述")
    private String desc;


    public static Week match(String val, Week def) {
        for (Week enm : Week.values()) {
            if (enm.name().equalsIgnoreCase(val)) {
                return enm;
            }
        }
        return def;
    }

    public static Week get(String val) {
        return match(val, null);
    }

    public boolean eq(String val) {
        return this.name().equalsIgnoreCase(val);
    }

    public boolean eq(Week val) {
        if (val == null) {
            return false;
        }
        return eq(val.name());
    }


    @Override
    public String getCode() {
        return BaseEnum.super.getCode();
    }

    @Override
    public String getDesc() {
        return this.desc;
    }
}
